//
//  TestViewController.swift
//  SwiftTest
//
//  Created by Mjwon on 2017/7/10.
//  Copyright © 2017年 Nemo. All rights reserved.
//

import UIKit

class TestViewController: UIViewController {

    typealias SectionHeaderClick = (String)->Void;
    var headerClick:SectionHeaderClick?;
    
    private var _viewModels:NSMutableArray?;
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.backgroundColor = UIColor.red;
        
        
        test();
    
    }
    
    func test() -> Void {
        
        
        
        for i  in 0...10 {
            DispatchQueue.global().async {
                print(i,Thread.current)
                DispatchQueue.main.async(execute: {
                    if i == 4{
                        print("----this is 4----",Thread.current);
                        return;
                    }
                })
            }
        }
        
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        
        print("---------")
        
        let viewModels = self.viewModels;
        
        
        let r:Bool = true;
        
        
        if viewModels.count > 0,r == true {
            print("this is true");
        }
        
        print(viewModels);
        
        self.headerClick?("name")
        
    }
    
    var viewModels:NSMutableArray{
        
        get{
        
            if _viewModels == nil {
                _viewModels = NSMutableArray.init();
            }
            
            if (_viewModels!.count > 0) {
            
            
            
            }else{
            
                for i  in 0...10 {
                    _viewModels!.add(i);
                }
                
            }
            
            
            return _viewModels!;
        }
    
    
    }
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
